$(function () {
    let mychart = echarts.init(document.querySelector('.threeBox .body'))
    let option = {
        title: [{
                text: '标题1',
                x: '20%',
                y: '5%',
                textStyle: {
                    fontSize: 16,
                    color:"white",
                }
            },
            {
                text: '标题2',
                x: '70%',
                y: '5%',
                textStyle: {
                    fontSize: 16,
                    color:"white",
                }
            }
        ],
        grid: {
            bottom:0,
        },
        color: ['#4c98dc', '#ea717a', '#6dcbb3'],
        legend: { 
            textStyle: { //图例文字的样式
                color: 'white',
                fontSize: 12
            },
            top: 0,
            x: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: '{b} :  ({d}%)'
        },
        dataset: {
            source: [
                ['group', '标题1', '标题2'],
                ['类型1', 57.02, 48.55],
                ['类型2', 27.09, 16.03],
                ['类型3', 15.89, 35.42]
            ]
        },
        series: [{
                type: 'pie',
                radius: [30, 60],
                center: ['25%', '50%'],
                encode: {
                    itemName: 'group',
                    value: '标题1'
                },
                label: {
                    show: true,
                    formatter: '{b}: {d}%'
                }
            },
            {
                type: 'pie',
                radius: [30, 60],
                center: ['75%', '50%'],
                encode: {
                    itemName: 'group',
                    value: '标题2'
                },
                label: {
                    show: true,
                    formatter: '{b}: {d}%'
                }
            }
        ]
    }

    mychart.setOption(option)
    window.addEventListener('resize', function () {
        mychart.resize()
    })
})